#! python
#! coding: utf-8

__author__ = 'Anton Vakhrushev'

import wx


class AuthDialog(wx.Dialog):
    """
    Пыш 123
    """
    def __init__(self, parent, username, password):
        wx.Dialog.__init__(self, parent, title='Authorization', size=(300, 145))

        self.username = username
        self.password = password

        sb = wx.StaticBitmap(self)
        sb.SetBitmap(wx.Bitmap('share/service_auth.png'))
        self.textLogin = wx.TextCtrl(self, value=self.username)
        self.textPass = wx.TextCtrl(self, style=wx.TE_PASSWORD, value=self.password)
        btnOk = wx.Button(self, wx.ID_OK)
        buttons = wx.StdDialogButtonSizer()
        buttons.AddButton(btnOk)
        buttons.AddButton(wx.Button(self, wx.ID_CANCEL))
        buttons.Realize()

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
        sizer1.Add(sb, 0, wx.ALL, 5)
        input_sizer = wx.FlexGridSizer(2, 2, 12, 12)
        input_sizer.AddGrowableCol(1)
        input_sizer.Add(wx.StaticText(self, label='Login:'))
        input_sizer.Add(self.textLogin, 0, wx.EXPAND | wx.ALL)
        input_sizer.Add(wx.StaticText(self, label='Password:'))
        input_sizer.Add(self.textPass, 0, wx.EXPAND | wx.ALL)
        sizer1.Add(input_sizer, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
        main_sizer.Add(sizer1, 0, wx.EXPAND | wx.ALL, 10)
        main_sizer.Add(buttons, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 20)

        self.SetSizer(main_sizer)
        self.Bind(wx.EVT_BUTTON, self.OnOK, btnOk)

    def OnOK(self, event):
        self.username = self.textLogin.GetValue()
        self.password = self.textPass.GetValue()
        self.EndModal(wx.ID_OK)
